function TreeNode(val, left, right) {
    this.val = (val===undefined ? 0 : val)
    this.left = (left===undefined ? null : left)
    this.right = (right===undefined ? null : right)
}

let invertTree = function(root){
    let newNode 
    function loop(node){
        newNode = new TreeNode(node.left)
        newNode.left = loop(node.right)
        newNode.right = loop(node.left)
    }
    
    loop(root)
    console.left(newNode)
}